﻿
@{
    ViewBag.Title = "Form";
    Layout = "~/Views/Shared/_Form.cshtml";
}

<form id="form1">
    <div class="container" style="margin-top: 10px; margin-left: -4%; ">
        <ul class="nav nav-tabs" role="tablist" id="myTab" style="margin-left: 4%;">
            <li role="presentation"><a href="" role="tab" data-toggle="tab">基本信息</a></li>
        </ul>
        <div class="tab-content">
            <div role="tabpanel" class="tab-pane fade in active" style="padding-top: 20px; margin-right: 99px; margin-left:69px;" id="basicInfo">
                <table class="form">
                    <tr>
                        <th class="formTitle"><span class="required">*</span>提醒类型：</th>
                        <td class="formValue formDdlSelectorTd">
                            @Html.DropDownList("reminderType", Newtouch.Infrastructure.EnmuReminderType.金额上限提醒.ToDescSelectList(), "==请选择==", new { @class = "form-control required" })
                        </td>
                    </tr>
                    <tr>
                        <th class="formTitle">@*<span class="required">*</span>*@科室：</th>
                        <td class="formValue">
                            <input type="text" class="form-control" id="ks" name="ks" placeholder="请空格或关键字进行选择" />
                        </td>
                    </tr>
                    <tr>
                        <th class="formTitle">@*<span class="required">*</span>*@医生：</th>
                        <td class="formValue">
                            <input type="text" class="form-control " id="ys" name="ys" placeholder="请空格或关键字进行选择"/>
                        </td>
                    </tr>
                    <tr>
                        <th class="formTitle">金额上限（元）：</th>
                        <td class="formValue">
                            <input type="text" class="form-control required" id="jesx" name="jesx" />
                        </td>
                    </tr>
                    <tr>
                        <th class="formTitle">有效：</th>
                        <td class="formValue">
                            <div class="ckbox">
                                <input id="zt" name="zt" type="checkbox" checked="checked"><label for="zt"></label>
                            </div>
                        </td>
                    </tr>
                </table>
            </div>
        </div>
    </div>
</form>

<script>
    var sxtxId = $.request("sxtxId");
    $(function () {
        $('#reminderType').select2({
            minimumResultsForSearch: -1
        });

        if (!!sxtxId) {
            $.najax({
                url: "/SystemManage/MoneyUpperLimitReminder/GetFormJson?r=" + Math.random(),
                data: { sxtxId: sxtxId },
                dataType: "json",
                async: false,
                success: function (data) {
                    $("#form1").formSerialize(data);
                    $('#ks').attr('data-Code', data.ksCode);
                    $('#ys').attr('data-gh', data.ysGh);
                }
            });
        }
    })

    //科室浮层
    $('#ks').newtouchBatchFloatingSelector({
        width: 300,
        height: 250,
        clickautotrigger: true,
        //minlength: 2,
        caption: "选择科室",
        url: '/SystemManage/MoneyUpperLimitReminder/SelectDepartmentList',
        ajaxparameters: function ($thisinput) {
            return "keyword=" + $thisinput.val();
        },
        //itemdbclickhandler: function ($thistr) {
        //    $('#ks').attr('data-Code', $thistr.attr('data-Code'))
        //        .val($thistr.attr('data-Name'));
        //    $('#ys').attr('data-gh', '')
        //        .val(''); //清空医生
        //},
        colModel: [
            { label: '代码', name: 'Code', widthratio: 40 },
            { label: '名称', name: 'Name', widthratio: 60 }
        ]
    });

    //$('#ys').focus(function () {
    //    if (!!!$('#ks').attr('data-Code') || !!!$('#ks').val()) {
    //        $.modalAlert("请先选择科室", 'warning');
    //        return;
    //    }
    //});
    //$('#ys').change(function () {
    //    if (!!!$('#ks').attr('data-Code') || !!!$('#ks').val()) {
    //        $.modalAlert("请先选择科室", 'warning');
    //        return;
    //    }
    //});

    //医生浮层
    $('#ys').newtouchBatchFloatingSelector({
        width: 300,
        height: 200,
        //minlength: 2,
        caption: "选择医生",
        clickautotrigger: true,
        url: '/SystemManage/MoneyUpperLimitReminder/SelectTherapistList',
        ajaxparameters: function ($thisinput) {
            return "keyword=" + $thisinput.val() + "&ks=" +  $('#ks').attr('data-Code');
        },
        //itemdbclickhandler: function ($thistr) {
        //    $('#ys').attr('data-gh', $thistr.attr('data-StaffGh'))
        //        .val($thistr.attr('data-StaffName'));
        //},
        //inputtextcheck: function (ysVal) {
        //    if (!!!$('#ks').attr('data-Code') || !!!$('#ks').val()) {
        //        return false;
        //    }
        //    return true;
        //},
        colModel: [
            { label: '工号', name: 'StaffGh', widthratio: 40 ,align: 'center'},
            { label: '名称', name: 'StaffName', widthratio: 60, align: 'center' }
        ]
    });


    //提交
    function submitForm() {
        if (!$('#form1').formValid()) {
            return false;
        }
        if (isNaN($('#jesx').val())) {
            $.modalAlert("金额上限仅可填写数字", 'warning');
            return false;
        }
        var params = $("#form1").formSerialize();
        //params.ks = $('#ks').attr('data-Code');
        //params.ys = $('#ys').attr('data-gh');
        $.submitForm({
            url: "/SystemManage/MoneyUpperLimitReminder/SubmitForm?sxtxId=" + sxtxId,
            param: params,
            success: function () {
                $.currentWindow().$("#gridList").resetSelection();
                $.currentWindow().$("#gridList").trigger("reloadGrid");
            }
        })
    }
</script>

